package reflect;

import java.lang.reflect.Method;

public class ReflectDemo5 {
    public static void main(String[] args) throws Exception{
        Person p = new Person();
        p.say("hello world");

        Class<?> cls = Class.forName("reflect.Person");
        Object obj = cls.newInstance();

        Method method = cls.getMethod("say", String.class);
        method.invoke(obj, "hello world");

        Method method1 = cls.getMethod("say", String.class, int.class);
        method1.invoke(obj, "ok", 3);
    }
}
